/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.Controller;

import com.spring.Beans.AlumnoBean;
import com.spring.Service.AlumnoService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

/** 
 *
 * @author kerife
 */
public class AlumnoController2 extends SimpleFormController {
    
    private AlumnoService alumnoService;

    public AlumnoService getAlumnoService() {
        return alumnoService;
    }

    public void setAlumnoService(AlumnoService alumnoService) {
        this.alumnoService = alumnoService;
    }
    
    public AlumnoController2() {
        //Initialize controller properties here or 
        //in the Web Application Context

        setCommandClass(AlumnoBean.class);
        setCommandName("AlumnoBean");//Las varaibles que va a utilizar la página
        setSuccessView("index"); //Vista siguiente
        setFormView("Formulario"); //Vista actual
    }
    
//    @Override
//    protected void doSubmitAction(Object command) throws Exception {
//        throw new UnsupportedOperationException("Not yet implemented");
//    }
    //Use onSubmit instead of doSubmitAction 
    //when you need access to the Request, Response, or BindException objects
    
       
    
    @Override
    protected ModelAndView onSubmit(Object command)throws Exception {
//    HttpServletRequest request, 
//    HttpServletResponse response, 
    AlumnoBean AluB = (AlumnoBean) command;
    ModelAndView mv = new ModelAndView(getSuccessView());
    mv.addObject("Altas",alumnoService.Validar());
        
    //Do something...
    return mv;
    }
}
